package com.examination.exam.controller;

import com.examination.auth.utils.SecurityUtil;
import com.examination.domain.common.ResponseResult;
import com.examination.domain.exam.vo.ExamPaperVo;
import com.examination.exam.service.ExamPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/exam/")
public class ExamPaperController {

    @Autowired
    private ExamPaperService examPaperService;

    @GetMapping("/get/{examId}/")
    public ResponseResult hasExam(@PathVariable String examId) {
        ExamPaperVo examPaperVo = examPaperService.getExam(String.valueOf(SecurityUtil.getUserId()), examId);
        System.out.println(examPaperVo);
        return ResponseResult.okResult(examPaperVo);
    }

    @PostMapping("/begin/{examId}/")
    public ResponseResult beginExam(@PathVariable String examId) {
        ExamPaperVo examPaperVo = examPaperService.getExam(String.valueOf(SecurityUtil.getUserId()), examId);
        System.out.println(examPaperVo);
        return ResponseResult.okResult(examPaperVo);
    }
}
